<!--
 * @Author: lwHao
 * @Date: 2020-10-23 16:01:40
 * @LastEditors: lwHao
 * @LastEditTime: 2020-10-23 16:25:25
-->
<template>
  <div>
    <h1>posts</h1>
    <div v-for="post in posts">{{ post }}</div>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
  name: 'posts',
  data() {
    return {

    }
  },
  computed: {
    ...mapState(['posts']),
  },
  // Vue SSR 特殊为服务端渲染提供的一个生命周期钩子函数
  serverPrefetch() {
    // 发起 action, 返回Promise
    return this.getPosts()
  },
  methods: {
    ...mapActions(['getPosts'])
  }

}
</script>

<style>
</style>